import allure

from base.base_page import BasePage
from locator.login_page_loc import *


class LoginPage(BasePage):
    def login(self,username,password):
        with allure.step(f"输入用户名：{username}，密码：{password}，登录"):
            self.send_keys(username_loc,username)
            self.send_keys(password_loc,password)
            self.click(login_btn_loc)

    @allure.step("点击登录页注册按钮")
    def register_entrance(self):
        self.click(register_btn_loc)

    @allure.step("获取注册页标题'登陆读书屋'")
    def get_title_text(self):
        txt = self.get_text(title_loc)
        return txt

    @allure.step("获取登录失败提示信息")
    def get_login_error_msg(self):
        msg = self.get_text(error_msg_loc)
        return msg

    @allure.step("获取登录成功显示的账号信息")
    def get_login_success_result(self, txt):
        result = self.text_wait(success_msg_loc, txt)
        return result

